package com.tsunami.auth.service.auth.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tsunami.auth.mapper.RoleOrgMapper;
import com.tsunami.auth.service.auth.IRoleOrgService;
import com.tsunami.authority.entity.auth.RoleOrg;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 角色组织关系表 服务实现类
 * </p>
 *
 * @author lx
 * @since 2021-09-23
 */
@Service
public class RoleOrgServiceImpl extends ServiceImpl<RoleOrgMapper, RoleOrg> implements IRoleOrgService {

    @Override
    public List<Long> listOrgByRoleId(Long id) {
        QueryWrapper param = new QueryWrapper();
        param.eq("role_id",id);
        List<RoleOrg> list = super.list(param);
        List<Long> orgList = list.stream().mapToLong(RoleOrg::getOrgId).boxed().collect(Collectors.toList());
        return orgList;
    }
}
